/* Exercise 5.30
   ejer5_30.c */
#include <stdio.h>

int qualityPoints( int average );

/* function main begins program execution */
int main( void )
{
    int average;

    printf( "Enter the student average: ");
    scanf( "%d", &average );

    printf( "The result is: %d\n", qualityPoints(average));
	return 0; /* indicate that program ended successfully */
} /* end function main */

int qualityPoints( int average )
{
    if ( average >= 80 )
        if ( average >= 90 )
            return 4;
        else
            return 3;
    else
        if ( average >= 60 )
            if ( average >= 70 )
                return 2;
            else
                return 1;
        else
            return 0;
}
